Imports System.IO

Module TodaysFiles

    Public Today As DateTime

    Function SameDate(ByVal A As DateTime, ByVal B As DateTime) As Boolean
        Return  (A.Year = B.Year) And (A.DayOfYear = B.DayOfYear) 
    End Function

    Sub SearchFolder(ByVal Dir As String)
        Dim Files As String() = Directory.GetFiles(Dir)
        Dim Dirs As String() 
	    Dirs= Directory.GetDirectories(Dir)

        Dim Filename As String

        Dim FileDateTime As DateTime
        For Each Filename In Files
                FileDateTime =File.GetCreationTime(Filename)

                If SameDate(FileDateTime, Today) Then
                       Console.WriteLine(Filename)
                End If
        Next

        Dim DirectoryName As String
        Dim DirectoryDateTime As DateTime
        For Each DirectoryName In Dirs
                DirectoryDateTime = Directory.GetCreationTime(DirectoryName)

                If SameDate(DirectoryDateTime, Today) Then
                    Console.WriteLine(DirectoryName)
                End If

                SearchFolder(DirectoryName)
        Next
    End Sub

    Sub Main()
        Today = DateTime.Today

        Console.WriteLine("Tim kiem file ngay {0}...", Today)
        SearchFolder("C:\VB2005.2")
    End Sub

End Module
